//
//  BaseTabBarController.m
//  StockpdfReading
//
//  Created by 于洪东 on 2017/6/17.
//  Copyright © 2017年 上海LOL信息技术服务有限公司. All rights reserved.
//

#import "BaseTabBarController.h"
#import "BaseNavigationController.h"


@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addChildViewControllers];
}

- (void)addChildViewControllers {
    
    [self setupChildViewControllerWithVcString:@"FirstViewController" imageName:@"tab_loan" selectedImage:@"tab_loan_Selected" title:@"学习" tag:0];
    
    [self setupChildViewControllerWithVcString:@"SecondViewController" imageName:@"tab_repayment" selectedImage:@"tab_repayment_sel" title:@"概率" tag:1];
    
    [self setupChildViewControllerWithVcString:@"ThirdViewController" imageName:@"tab_activity" selectedImage:@"tab_activity_sel" title:@"资讯" tag:2];
    
//    [self setupChildViewControllerWithVcString:@"SuperBookVC" imageName:@"tab_activity" selectedImage:@"tab_activity_sel" title:@"经典" tag:2];
//    
//    [self setupChildViewControllerWithVcString:@"UserVC" imageName:@"tab_me" selectedImage:@"tab_me_sel" title:@"我的" tag:3];
    
}

- (void)setupChildViewControllerWithVcString:(NSString *)vcString imageName:(NSString *)imageName selectedImage:(NSString *)selectedImage title:(NSString *)title  tag:(NSInteger)tag{
    Class cls = NSClassFromString(vcString);
    UIViewController *vc = [[cls alloc] init];
    vc.title = title;
    vc.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.tag = tag;
    
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xff6268)} forState:UIControlStateSelected];
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x878787)} forState:UIControlStateNormal];
    BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
    
}

@end
